Fix incidents get/update/delete with sequential IDs (INC-xxx)#32
Conversation
The Rootly API accepts UUID, slug, or bare numeric sequential ID but not the "INC-123" display format. NormalizeIncidentID strips the prefix so `rootly incidents get INC-31` hits /v1/incidents/31 instead of /v1/incidents/INC-31 which 404'd. Closes #28 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Greptile SummaryThis PR fixes
Confidence Score: 4/5Safe to merge; the core normalization logic is correct and well-tested, with only a minor UX inconsistency in how error messages for The normalization regex, its placement, and the split between internal/cmd/incidents/get.go — the original input ID is not retained for error message display Important Files Changed
Prompt To Fix All With AIFix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
internal/cmd/incidents/get.go:39-40
The PR's stated goal is for user-facing messages to keep the original `INC-xxx` format, and `delete`/`update` both achieve this via a separate `displayID`. In `runGet`, only the normalized `id` is stored, so a 404 error bubbles up as `"failed to get incident: incident not found: 999"` rather than `"incident not found: INC-999"`. Storing the original input and using it in the error wrapping keeps the UX consistent.
```suggestion
func runGet(cmd *cobra.Command, args []string) error {
displayID := args[0]
id := api.NormalizeIncidentID(displayID)
```
Reviews (1): Last reviewed commit: "🐛 fix: resolve incidents get/update/del..." | Re-trigger Greptile |
| func runGet(cmd *cobra.Command, args []string) error { | ||
| // Get incident ID from args | ||
| id := args[0] | ||
| id := api.NormalizeIncidentID(args[0]) |
There was a problem hiding this comment.
The PR's stated goal is for user-facing messages to keep the original
INC-xxx format, and delete/update both achieve this via a separate displayID. In runGet, only the normalized id is stored, so a 404 error bubbles up as "failed to get incident: incident not found: 999" rather than "incident not found: INC-999". Storing the original input and using it in the error wrapping keeps the UX consistent.
| func runGet(cmd *cobra.Command, args []string) error { | |
| // Get incident ID from args | |
| id := args[0] | |
| id := api.NormalizeIncidentID(args[0]) | |
| func runGet(cmd *cobra.Command, args []string) error { | |
| displayID := args[0] | |
| id := api.NormalizeIncidentID(displayID) |
Prompt To Fix With AI
This is a comment left during a code review.
Path: internal/cmd/incidents/get.go
Line: 39-40
Comment:
The PR's stated goal is for user-facing messages to keep the original `INC-xxx` format, and `delete`/`update` both achieve this via a separate `displayID`. In `runGet`, only the normalized `id` is stored, so a 404 error bubbles up as `"failed to get incident: incident not found: 999"` rather than `"incident not found: INC-999"`. Storing the original input and using it in the error wrapping keeps the UX consistent.
```suggestion
func runGet(cmd *cobra.Command, args []string) error {
displayID := args[0]
id := api.NormalizeIncidentID(displayID)
```
How can I resolve this? If you propose a fix, please make it concise.Keeps displayID separate from normalized ID in runGet, consistent with update and delete commands. Error now shows "failed to get incident INC-999" instead of bare "999". 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Summary
rootly incidents get INC-31was failing with "incident not found" because the CLI passedINC-31verbatim to/v1/incidents/INC-31, but the API expects UUID, slug, or bare numeric sequential IDNormalizeIncidentID()to strip theINC-prefix (case-insensitive), soINC-31→31before hitting the APIget,update, anddeletecommands; user-facing messages still show the originalINC-xxxformatCloses #28
Test plan
TestNormalizeIncidentID— 9 cases covering INC-prefix, UUIDs, slugs, edge casesTestRunGetNormalizesSequentialID— verifies API receives/v1/incidents/42when givenINC-42TestRunGetAcceptsUUID— verifies UUIDs pass through unchangedrootly incidents get INC-31returns correct incident